<include file="Public/head" />
<include file="Public/common_header" />
<script src="{:get_style_cdnurl()}paimai/yunying/js/global.js"></script>
<div class="yunBei"></div>
<div class="mian">
    <include file="Public/sidebar" menu="spgl.spsh"  />
    <div class="mianR">
        <h3 class="yonghu">上拍审核</h3>
        <div class="yuyue">
            <ul>
                <li onclick="change_search(0);get_list(1);" class="yuCurrent">待审核</li>
                <li onclick="change_search(1);get_list(2);">审核驳回</li>
                <li onclick="change_search(2);get_list(3);">审核通过</li>
                <!--(1 待审核,2 审核驳回,3 审核通过)-->
            </ul>
            <input type="hidden" name="status" value="1" />
        </div>
        <div class="shangFrom shangFrom1 clearfix">
            <form id="searchFrom">
                <input id="status" name="status" type="hidden" value="{$params.status}"/>
                <div id="search1">
                    <div class="zhuang-tai">
                        <input type="text" class="paichang" value="请选择上拍场次" readonly/>
                        <dl class="scene" style="left: 5px;">
                            <input type="hidden" name="scene_id" value="" />
                            <dd data=''>请选择上拍场次</dd>
                            <foreach name="scenes" item="scene">
                                <php>
                                    $time = date('H',strtotime($scene[starttime]));
                                    $name = $time.'点场';
                                </php>
                                <dd data="{$scene.scene_id}">{$name}({$scene.name})</dd>
                            </foreach>
                        </dl>
                    </div>
                </div>
                <div class="zhuang-tai"  style="width: 188px;">
                    <select id="location_area" name="location_area" class="branch_company" style="height: 24px; line-height: 24px;">
                        <if condition="count($bc_city) gt 1">
                            <option value="">请选择所在地</option>
                        </if>
                        <volist name="bc_city" id="city">
                            <option value="{$key}">{$city}</option>
                        </volist>
                    </select>
                </div>

                <!--<div class="zhuang-tai zhuang-tai1">
                    <input name="order_status" type="text" data="" value="选择状态"  class="obtain" readonly />
                    <dl class="status">
                        <dd data="">选择状态</dd>
                        <dd data="1">待审核</dd>
                        <dd data="2">审核驳回</dd>
                        <dd data="3">审核成功</dd>
                    </dl>

                </div>-->
                <div class="zhuang-tai zhuang-tai1" style="margin-right: 4px;"><input type="text" name="bidding_start_time"  placeholder="请选择竞拍日期" class="end-time" id="demoText2" readonly /></div>

                <div class="deng-ji"><input type="text" name="keyword" id="order_id" placeholder="拍卖单号、等级" onfocus="if (this.value == '拍卖单号、等级') {
                            this.value = ''
                        }" onblur="if (this.value == '') {
                                    this.value = '拍卖单号、等级'
                                }"/></div>
                <div class="shangSou"><input type="button" id="searchBtn"  value="搜索"/></div>
            </form>
        </div>

        <div class="listBox" id="listBox"></div>

        <div class="clear"></div>
    </div>
</div>
<!--审核通过-->
<div class="chenggong1">
    <span class="paidan">您确定要拍单<i>通过</i>审核吗?</span>
    <div class="shenhei-btn">
        <input type="hidden" name="act"  value="" />
        <input type="hidden" name="order_id"  value="" />
        <input type="button" value="确定" class="determine" />
        <input type="button" value="取消" class="cancel" />
    </div>
</div>

<script type="text/javascript">




    get_list(1);
    function get_list(status) {
       // $('#car_status').val(status);
        $('input[name=status]').val(status);
        var url = mkurl();
        console.log(url)
        $.get(url, {"status": status} , function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    //ajax 获取分页内容
    function get_page(p) {
//        var paramer = "order_status=" + $('input[name=order_status]').attr('data') + "&" + encodeURI("p=" + p);
        var url = mkurl();
        var paramer = $("#searchFrom").serialize()+'&p='+p;
        $.get(url, paramer, function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    //审核确认窗口
    function audit(order_id, act) {
        $('.chenggong1').css('display', 'block');
        $('.yunBei').css({'display':'block',"zIndex":999});
        if(act == 'reject'){
            $('.chenggong1 span').after('<textarea id="remark_reject" placeholder="驳回原因"></textarea>');
        }
        $('input[name=order_id]').val(order_id);
        if (act == 'pass') {
            $('.paidan i').text('通过');
            $('input[name=act]').val('pass');
        } else if (act == 'reject') {
            $('.paidan i').text('驳回');
            $('input[name=act]').val('reject');
        }
    }
    //
    $(".determine").on('click', function () {
        var act = $('input[name=act]').val();
        var order_id = $('input[name=order_id]').val();
        var param = {};
        if(act == 'reject'){
            var remark_reject = $('#remark_reject').val();
            if(remark_reject == '' || remark_reject == null){
                shibai_alert1('驳回原因不能为空');
                //$('.yunBei').css({'display':'block',"zIndex":999});
                return false;
            }
            param = {
                'act': act,
                'order_id': order_id,
                'remark_reject': remark_reject,
            };
        }else{
            param = {
                'act': act,
                'order_id': order_id,
            };
        }
        //alert(param.remark_reject);return;
        var remark_reject = $('#remark_reject').val();
        var btn_obj = $(this);
        btn_obj.val("提交中...").attr("disabled",'disabled');
        $.post('/AuOrder/audit', param, function (data) {
            if (data.code == '200') {
                btn_alert(data.msg);
                $('.chenggong1').fadeOut();
                //event.stopPropagation()
                get_list(1);
                btn_obj.val("确定").removeAttr("disabled style");
            } else {
                shibai_alert(data.msg)
                btn_obj.val("确定").removeAttr("disabled style");
                $('.chenggong1').fadeOut();
            }
            $('.chenggong1 textarea').remove();
            $('.yunBei').css({'display':'none',"zIndex":999});
        }, 'json');
    });
    $(".cancel").on('click', function () {
        $('.chenggong1').fadeOut();
        $('.yunBei').css({'display':'none',"zIndex":999});
        $('.chenggong1 textarea').remove();
    });
    //搜索
    $("#searchBtn").on('click', function () {
        var url = mkurl();
        var param = {};
        console.log(url)
        $.get(url, param, function (data) {
            $("#listBox").html(data);
        }, "html");
    });

    function mkurl(){
        var url = '/AuOrder/get_list';
        var param = {};
        var scene_id = $('input[name=scene_id]').val();
        if (scene_id) {
            url += '/scene_id/' + scene_id;
        }

        var status = $('input[name=status]').val();
        if (status) {
            url += '/status/' + status;
        }
        var location_area = $('select[name=location_area]').val();
        if (location_area) {
            url += '/location_area/' + location_area;
        }
        var bidding_start_time = $('input[name=bidding_start_time]').val();
        if (bidding_start_time && bidding_start_time != "请选择竞拍日期") {
            url += '/bidding_start_time/' + bidding_start_time;
        }
        var keyword = $('input[name=keyword]').val();
        if (keyword && (keyword != '拍卖单号、等级')) {
            url += '/keyword/' + encodeURIComponent(keyword);
        }
        return url;
    }
    
    //选择场次后把值赋于 name  为 scene的控件
    $(".scene dd").on('click', function () {
        console.log($(this).attr('data'))
        $("input[name=scene_id]").val($(this).attr('data'));
    });
    //状态赋值
    $(".status dd").click(function () {
        $('input[name=order_status]').attr('data', ($(this).attr('data')));
    });
    //时间赋值

    //页签切换，显示不同的搜索条件
    function change_search(st) {
        var s1 = $("#search1");
        clear_params();
        if (st == 1 || st == 2 ) {
            s1.hide();
        }else{
            s1.show();
        }
    }

    function clear_params() {
        $("#order_id").val("");
        $("#demoText2").val("");
    }
</script>
<include file="Public/foot" />